package cn.south.campus.admin.campus.controller;

import cn.south.campus.admin.campus.model.req.ComplaintReq;
import cn.south.campus.admin.campus.model.vo.ComplaintVo;
import cn.south.campus.admin.campus.service.ComplaintService;
import cn.south.campus.common.model.bo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *
 * </p>
 *
 * @author chow
 * @since 2024/12/5 13:18
 */
@RestController
@AllArgsConstructor
@RequestMapping("/admin/complaint")
public class ComplaintController {

    private final ComplaintService complaintService;

    @GetMapping("/page")
    public Result<IPage<ComplaintVo>> page(ComplaintReq query) {
        IPage<ComplaintVo> page = complaintService.pageQuery(query);
        return Result.success(page);
    }

    @GetMapping("/detail/{id}")
    public Result<ComplaintVo> detail(@PathVariable Long id) {
        ComplaintVo complaintVo = complaintService.detail(id);
        return Result.success(complaintVo);
    }

    @PutMapping("/updateStatus/{id}/{status}")
    public Result<String> updateStatus(@PathVariable Long id, @PathVariable Integer status) {
        complaintService.updateStatusComplaint(id, status);
        return Result.success("修改成功");
    }
}
